<html>

<body>
<!--<script>
  document.addEventListener('DOMContentLoaded', function() {
  // 获取所有的input元素，阻止它们自动聚焦
  var inputs = document.getElementsByTagName('input');
  for (var i = 0; i < inputs.length; i++) {
    inputs[i].autofocus = false; // 或者使用inputs[i].blur()在页面加载后立即移除焦点
  }
});
</script>-->
  <script>
    // Based on: https://manfredsteyer.github.io/angular-oauth2-oidc/docs/additional-documentation/silent-refresh.html

    const checks = [/[\?|&|#]code=/, /[\?|&|#]error=/, /[\?|&|#]token=/, /[\?|&|#]id_token=/];

    function isResponse(str) {
      if (!str) return false;
      for (var i = 0; i < checks.length; i++) {
        if (str.match(checks[i])) return true;
      }
      return false;
    }

    //let message = isResponse(location.hash) ? location.hash : '#' + location.search;
    var message = isResponse(location.hash)
      ? location.hash
      : '#' + location.search;

            //Silent refresh iframe is posting to the parent application, message:
    console.log("静默刷新iframe向父应用程序发送消息,message= ", message);
    console.log("静默父应用程序Url: ", location.origin+" | "+location.hash);    //4200

    //(window.opener || window.parent).postMessage(message, location.origin);

    if (window.parent && window.parent !== window) {
      // if loaded as an iframe during silent refresh
      console.log("静默刷新iframe向父应用程序发送消息: ", window.parent.location);
      window.parent.postMessage(message, location.origin);  //location.origin
    } else if (window.opener && window.opener !== window) {
      // if loaded as a popup during initial login
      window.opener.postMessage(message, location.origin);
    } else {
      // last resort for a popup which has been through redirects and can't use window.opener
      localStorage.setItem('auth_hash', message);
      localStorage.removeItem('auth_hash');
    }

  </script>
</body>

</html>
